home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / mint104s.zoo / mint.src / file.h < prev    next >
C/C++ Source or Header  |  1993-03-08  |  17KB  |  526 lines

  1. /*
  2. Copyright 1991,1992 Eric R. Smith.
  3. Copyright 1992 Atari Corporation.
  4. All rights reserved.
  5. */
  6.  
  7. #ifndef _filesys_h
  8. #define _filesys_h
  9.  
  10. struct filesys;        /* forward declaration */
  11. struct devdrv;        /* ditto */
  12.  
  13. typedef struct f_cookie {
  14.     struct filesys *fs;    /* filesystem that knows about this cookie */
  15.     ushort    dev;        /* device info (e.g. Rwabs device number) */
  16.     ushort    aux;        /* extra data that the file system may want */
  17.     long    index;        /* this+dev uniquely identifies a file */
  18. } fcookie;
  19.  
  20. #define TOS_NAMELEN 13
  21.  
  22. typedef struct dtabuf {
  23.     short    index;        /* index into arrays in the PROC struct */
  24.     long    magic;
  25. #define SVALID    0x1234fedcL    /* magic for a valid search */
  26. #define EVALID    0x5678ba90L    /* magic for an exhausted search */
  27.  
  28.     char    dta_pat[TOS_NAMELEN+1];    /* pointer to pattern, if necessary */
  29.     char    dta_sattrib;    /* attributes being searched for */
  30. /* this stuff is returned to the user */
  31.     char    dta_attrib;
  32.     short    dta_time;
  33.     short    dta_date;
  34.     long    dta_size;
  35.     char    dta_name[TOS_NAMELEN+1];
  36. } DTABUF;
  37.  
  38. /* structure for opendir/readdir/closedir */
  39. typedef struct dirstruct {
  40.     fcookie fc;        /* cookie for this directory */
  41.     ushort    index;        /* index of the current entry */
  42.     ushort    flags;        /* flags (e.g. tos or not) */
  43. #define TOS_SEARCH    0x01
  44.     char    fsstuff[60];    /* anything else the file system wants */
  45.                 /* NOTE: this must be at least 45 bytes */
  46.     struct dirstruct *next;    /* linked together so we can close them
  47.                    on process termination */
  48. } DIR;
  49.  
  50. /* structure for getxattr */
  51. typedef struct xattr {
  52.     ushort    mode;
  53. /* file types */
  54. #define S_IFMT    0170000        /* mask to select file type */
  55. #define S_IFCHR    0020000        /* BIOS special file */
  56. #define S_IFDIR    0040000        /* directory file */
  57. #define S_IFREG 0100000        /* regular file */
  58. #define S_IFIFO 0120000        /* FIFO */
  59. #define S_IMEM    0140000        /* memory region or process */
  60. #define S_IFLNK    0160000        /* symbolic link */
  61.  
  62. /* special bits: setuid, setgid, sticky bit */
  63. #define S_ISUID    04000
  64. #define S_ISGID 02000
  65. #define S_ISVTX    01000
  66.  
  67. /* file access modes for user, group, and other*/
  68. #define S_IRUSR    0400
  69. #define S_IWUSR 0200
  70. #define S_IXUSR 0100
  71. #define S_IRGRP 0040
  72. #define S_IWGRP    0020
  73. #define S_IXGRP    0010
  74. #define S_IROTH    0004
  75. #define S_IWOTH    0002
  76. #define S_IXOTH    0001
  77. #define DEFAULT_DIRMODE (0777)
  78. #define DEFAULT_MODE    (0666)
  79.     long    index;
  80.     ushort    dev;
  81.     ushort    reserved1;
  82.     ushort    nlink;
  83.     ushort    uid;
  84.     ushort    gid;
  85.     long    size;
  86.     long    blksize;
  87.     long    nblocks;
  88.     short    mtime, mdate;
  89.     short    atime, adate;
  90.     short    ctime, cdate;
  91.     short    attr;
  92. /* defines for TOS attribute bytes */
  93. #ifndef FA_RDONLY
  94. #define           FA_RDONLY           0x01
  95. #define           FA_HIDDEN           0x02
  96. #define           FA_SYSTEM           0x04
  97. #define           FA_LABEL               0x08
  98. #define           FA_DIR               0x10
  99. #define           FA_CHANGED           0x20
  100. #endif
  101.     short    reserved2;
  102.     long    reserved3[2];
  103. } XATTR;
  104.  
  105. typedef struct fileptr {
  106.     short    links;        /* number of copies of this descriptor */
  107.     ushort    flags;        /* file open mode and other file flags */
  108.     long    pos;        /* position in file */
  109.     long    devinfo;    /* device driver specific info */
  110.     fcookie    fc;        /* file system cookie for this file */
  111.     struct devdrv *dev; /* device driver that knows how to deal with this */
  112.     struct fileptr *next; /* link to next fileptr for this file */
  113. } FILEPTR;
  114.  
  115. struct flock {
  116.     short l_type;            /* type of lock */
  117. #define F_RDLCK        0
  118. #define F_WRLCK        1
  119. #define F_UNLCK        3
  120.     short l_whence;            /* SEEK_SET, SEEK_CUR, SEEK_END */
  121.     long l_start;            /* start of locked region */
  122.     long l_len;            /* length of locked region */
  123.     short l_pid;            /* pid of locking process
  124.                         (F_GETLK only) */
  125. };
  126.  
  127. /* structure for internal kernel locks */
  128. typedef struct ilock {
  129.     struct flock l;        /* the actual lock */
  130.     struct ilock *next;    /* next lock in the list */
  131.     long    reserved[4];    /* reserved for future expansion */
  132. } LOCK;
  133.  
  134. typedef struct devdrv {
  135.     long ARGS_ON_STACK (*open)    P_((FILEPTR *f));
  136.     long ARGS_ON_STACK (*write)    P_((FILEPTR *f, const char *buf, long bytes));
  137.     long ARGS_ON_STACK (*read)    P_((FILEPTR *f, char *buf, long bytes));
  138.     long ARGS_ON_STACK (*lseek)    P_((FILEPTR *f, long where, int whence));
  139.     long ARGS_ON_STACK (*ioctl)    P_((FILEPTR *f, int mode, void *buf));
  140.     long ARGS_ON_STACK (*datime)    P_((FILEPTR *f, short *timeptr, int rwflag));
  141.     long ARGS_ON_STACK (*close)    P_((FILEPTR *f, int pid));
  142.     long ARGS_ON_STACK (*select)    P_((FILEPTR *f, long proc, int mode));
  143.     void ARGS_ON_STACK (*unselect) P_((FILEPTR *f, long proc, int mode));
  144. } DEVDRV;
  145.  
  146. typedef struct filesys {
  147.     struct    filesys    *next;    /* link to next file system on chain */
  148.     long    fsflags;
  149. #define FS_KNOPARSE    0x01    /* kernel shouldn't do parsing */
  150. #define FS_CASESENSITIVE    0x02    /* file names are case sensitive */
  151. #define FS_NOXBIT    0x04    /* if a file can be read, it can be executed */
  152. #define    FS_LONGPATH    0x08    /* file system understands "size" argument to
  153.                    "getname" */
  154.     long    ARGS_ON_STACK (*root) P_((int drv, fcookie *fc));
  155.     long    ARGS_ON_STACK (*lookup) P_((fcookie *dir, const char *name, fcookie *fc));
  156.     long    ARGS_ON_STACK (*creat) P_((fcookie *dir, const char *name, unsigned mode,
  157.                 int attrib, fcookie *fc));
  158.     DEVDRV * ARGS_ON_STACK (*getdev) P_((fcookie *fc, long *devspecial));
  159.     long    ARGS_ON_STACK (*getxattr) P_((fcookie *file, XATTR *xattr));
  160.     long    ARGS_ON_STACK (*chattr) P_((fcookie *file, int attr));
  161.     long    ARGS_ON_STACK (*chown) P_((fcookie *file, int uid, int gid));
  162.     long    ARGS_ON_STACK (*chmode) P_((fcookie *file, unsigned mode));
  163.     long    ARGS_ON_STACK (*mkdir) P_((fcookie *dir, const char *name, unsigned mode));
  164.     long    ARGS_ON_STACK (*rmdir) P_((fcookie *dir, const char *name));
  165.     long    ARGS_ON_STACK (*remove) P_((fcookie *dir, const char *name));
  166.     long    ARGS_ON_STACK (*getname) P_((fcookie *relto, fcookie *dir,
  167.                 char *pathname, int size));
  168.     long    ARGS_ON_STACK (*rename) P_((fcookie *olddir, char *oldname,
  169.                 fcookie *newdir, const char *newname));
  170.     long    ARGS_ON_STACK (*opendir) P_((DIR *dirh, int tosflag));
  171.     long    ARGS_ON_STACK (*readdir) P_((DIR *dirh, char *name, int namelen, fcookie *fc));
  172.     long    ARGS_ON_STACK (*rewinddir) P_((DIR *dirh));
  173.     long    ARGS_ON_STACK (*closedir) P_((DIR *dirh));
  174.     long    ARGS_ON_STACK (*pathconf) P_((fcookie *dir, int which));
  175.     long    ARGS_ON_STACK (*dfree) P_((fcookie *dir, long *buf));
  176.     long    ARGS_ON_STACK (*writelabel) P_((fcookie *dir, const char *name));
  177.     long    ARGS_ON_STACK (*readlabel) P_((fcookie *dir, char *name, int namelen));
  178.     long    ARGS_ON_STACK (*symlink) P_((fcookie *dir, const char *name, const char *to));
  179.     long    ARGS_ON_STACK (*readlink) P_((fcookie *dir, char *buf, int len));
  180.     long    ARGS_ON_STACK (*hardlink) P_((fcookie *fromdir, const char *fromname,
  181.                 fcookie *todir, const char *toname));
  182.     long    ARGS_ON_STACK (*fscntl) P_((fcookie *dir, const char *name, int cmd, long arg));
  183.     long    ARGS_ON_STACK (*dskchng) P_((int drv));
  184.     long    ARGS_ON_STACK (*release) P_((fcookie *));
  185.     long    ARGS_ON_STACK (*dupcookie) P_((fcookie *new, fcookie *old));
  186. } FILESYS;
  187.  
  188. /*
  189.  * this is the structure passed to loaded file systems to tell them
  190.  * about the kernel
  191.  */
  192.  
  193. struct kerinfo {
  194.     short    maj_version;    /* kernel version number */
  195.     short    min_version;    /* minor kernel version number */
  196.     ushort    default_perm;    /* default file permissions */
  197.     short    reserved1;    /* room for expansion */
  198.  
  199. /* OS functions */
  200.     Func    *bios_tab;    /* pointer to the BIOS entry points */
  201.     Func    *dos_tab;    /* pointer to the GEMDOS entry points */
  202.  
  203. /* media change vector */
  204.     void    ARGS_ON_STACK (*drvchng) P_((unsigned));
  205.  
  206. /* Debugging stuff */
  207.     void    ARGS_ON_STACK (*trace) P_((const char *, ...));
  208.     void    ARGS_ON_STACK (*debug) P_((const char *, ...));
  209.     void    ARGS_ON_STACK (*alert) P_((const char *, ...));
  210.     EXITING void ARGS_ON_STACK (*fatal) P_((const char *, ...));
  211.  
  212. /* memory allocation functions */
  213.     void *    ARGS_ON_STACK (*kmalloc) P_((long));
  214.     void    ARGS_ON_STACK (*kfree) P_((void *));
  215.     void *    ARGS_ON_STACK (*umalloc) P_((long));
  216.     void    ARGS_ON_STACK (*ufree) P_((void *));
  217.  
  218. /* utility functions for string manipulation */
  219.     int    ARGS_ON_STACK (*strnicmp) P_((const char *, const c